function fig2_left
close all
addpath ../

p = params;

set(0, 'defaulttextinterpreter','latex');
set(0,'defaulttextfontsize',12);


%----------------------------------------
% delta = 0.1
p.delta = 0.1;

s1 = base(p);

v1 = abs(s1.y(end-1,:));
h1 = s1.y(end,:);
t1 = s1.x;

t1_asy = logspace(log10(t1(2)), log10(t1(end)), 30);
h1_asy = -(1 + lambertw(-p.beta / (p.beta - 1) * exp(((-p.beta + p.delta * t1_asy) / (p.beta - 1))))) * (p.beta - 1);


v1_long = (1 - p.beta) * (1 - 1 ./ h1_asy);
v1_short = sep_var(0, p);


%----------------------------------------
% delta = 0.01
p.delta = 0.01;

s2 = base(p);

v2 = abs(s2.y(end-1,:));
h2 = s2.y(end,:);
t2 = s2.x;

t2_asy = logspace(log10(t2(2)), log10(t2(end)), 30);
h2_asy = -(1 + lambertw(-p.beta / (p.beta - 1) * exp(((-p.beta + p.delta * t2_asy) / (p.beta - 1))))) * (p.beta - 1);

v2_long = (1 - p.beta) * (1 - 1 ./ h2_asy);
v2_short = sep_var(0, p);

%--------------------------------------------
% now plot the stuff

subplot(2,1,1)
semilogx(t1, h1, 'k', 'linewidth',1);
hold on;
semilogx(t1_asy, h1_asy, 'k*');
semilogx(t2, h2, 'k--','linewidth',1);
semilogx(t2_asy, h2_asy, 'k^');
xlabel('$t$');
ylabel('$h$');
l = legend ('$\delta = 0.1$ numerical', '$\delta = 0.1$ asymptotic', ...
    '$\delta = 0.01$ numerical', '$\delta = 0.01$ asymptotic', ...
    'location','southwest');
set(l, 'interpreter','latex','fontsize',11);
legend boxoff
xlim([1e-6, p.Tmax]);
ylim([1 - p.beta, 1]);

subplot(2,1,2);
tmp = interp1(t1, abs(v1_short(p.N, :)), t1_asy);
loglog(t1, v1, 'k','linewidth',1);
hold on;
loglog(t1_asy, tmp, 'k*', t1_asy, abs(v1_long), 'ko');
ylim([1e-5, 1e1]);
set(gca, 'ytick',[1e-5, 1e-3, 1e-1, 1e1]);
xlabel('$t$');
ylabel('$\mathrm{max}\,\{|c|\}$');
l = legend('numerical','$t = O(1)$ asymptotic','$t = O(\delta^{-1})$ asymptotic');
set(l,'interpreter','latex','fontsize',10,'location','best');
xlim([1e-6, p.Tmax]);
legend boxoff